package cn.usian.pricingstrategy.passenger.service.impl;

import cn.usian.pojo.pricingstrategy.passenger.OperatePassengerCharges;
import cn.usian.pricingstrategy.passenger.mapper.PassengerMapper;
import cn.usian.pricingstrategy.passenger.service.IPassengerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;


@Service
@Slf4j
public class PassengerServiceImpl implements IPassengerService {
    @Autowired
    private PassengerMapper passengerMapper;

    @Override
    public String save(OperatePassengerCharges passengerCharges) {
        Optional<OperatePassengerCharges> charges = Optional.ofNullable(passengerCharges);
        if (charges.isPresent()) {
            log.info("更新参数:{}",passengerCharges);
            passengerMapper.update(passengerCharges);
            return "更新成功";
        }else{
            return "参数错误";
        }
    }

    @Override
    public List<OperatePassengerCharges> list() {
        return passengerMapper.list();
    }

    @Override
    public OperatePassengerCharges findById(long id) {
        OperatePassengerCharges byId = passengerMapper.findById(id);
        log.info("findById:{}",byId);
        return byId;
    }
}
